package com.example.card.abstracttransactions;

import com.example.card.CardDataBase;
import com.example.card.Transaction;
import com.example.card.domain.user.User;

public abstract class UserCheckTransaction implements Transaction {

    protected   int memberId;
    protected User user;

    public UserCheckTransaction(int memberId) {
        this.memberId = memberId;
    }

    protected UserCheckTransaction() {
    }

    public abstract void realExecute(User user);

    @Override
    public void execute() {
        user = CardDataBase.getUser(memberId);
        if (user == null) {
            throw new RuntimeException("用户不存在");
        }
        realExecute(user);
    }
}
